package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenDutyMessageDTO;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeHideDTO;
import com.hzeport.bgs22emduty.entity.ScreenDutyMessage;
import com.hzeport.bgs22emduty.enums.HideStatusEnum;
import com.hzeport.bgs22emduty.service.ScreenDutyMessageService;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screendutymessage")
@Api(value = "screendutymessage", tags = "值班信息管理")
@Slf4j
public class ScreenDutyMessageController {

    private final ScreenDutyMessageService screenDutyMessageService;

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult getScreenDutyMessagePage(@RequestBody ScreenDutyMessageDTO screenDutyMessage) {
        Page<ScreenDutyMessage>  dutyMessageList=screenDutyMessageService.page(screenDutyMessage);
        return BaseResult.ok(dutyMessageList);
    }


    /**
     * 通过id查询${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public BaseResult getById(@PathVariable("id") String id) {
        return BaseResult.ok(screenDutyMessageService.getById(id));
    }

    /**
     * 新增${comments}
     * @param screenDutyMessage ${comments}
     * @return R
     */
    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    @PostMapping("save")
    @OperLog(systemName = "ZBXX",description = "XXXZ")
    public BaseResult save(@RequestBody ScreenDutyMessage screenDutyMessage) {
        return BaseResult.ok(screenDutyMessageService.save(screenDutyMessage));
    }

    /**
     * 修改${comments}
     * @param screenDutyMessage ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
    @PostMapping("updateById")
    @OperLog(systemName = "ZBXX",description = "XXXG")
    public BaseResult updateById(@RequestBody ScreenDutyMessage screenDutyMessage) {
        return BaseResult.ok(screenDutyMessageService.update(screenDutyMessage));
    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    @DeleteMapping("/{id}")
    @OperLog(systemName = "ZBXX",description = "XXSC")
    public BaseResult removeById(@PathVariable String id) {
        return BaseResult.ok(screenDutyMessageService.removeById(id));
    }


    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id隐藏", notes = "通过id隐藏")
    @PostMapping("/hide")
    @OperLog(systemName = "ZBXX",description = "XXYC")
    public BaseResult hide(@Valid @RequestBody ScreenMessageDistributeHideDTO screenMessageDistributeHideDTO) {
        if (HideStatusEnum.NOT_HIDED.getValue().equals(screenMessageDistributeHideDTO.getStatus())) {
            return BaseResult.ok(screenDutyMessageService.hide(screenMessageDistributeHideDTO),"取消隐藏成功");
        }else {
            return BaseResult.ok(screenDutyMessageService.hide(screenMessageDistributeHideDTO),"隐藏成功");
        }
    }
}
